package org.monkey.request.plugin.advisor;

import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.aop.Advisor;
import org.springframework.aop.framework.adapter.AdvisorAdapter;

public class ResLogAdvisorAdapter implements AdvisorAdapter {

  @Override
  public boolean supportsAdvice(Advice advice) {
    return advice instanceof RequestLogAdvice;
  }

  @Override
  public MethodInterceptor getInterceptor(Advisor advisor) {
    RequestLogAdvice requestLogAdvice = (RequestLogAdvice) advisor.getAdvice();
    return requestLogAdvice::invoke;
  }

}
